<template>
  <div>
    <van-nav-bar
      class="nav"
      title="我的客户"
      left-text="返回"
      left-arrow
      @click-left="onClickLeft"
    />
    <van-search
      placeholder="请输入客户名称"
      @search="search"
      v-model="queryParam[0].Keyword"
      @clear="clear"
    />
    <div @click="Edit(item.Id)" class="box" v-for="item in data" :key="item.Id">
      <div class="Father">
        <img
          src="http://36.156.144.139:9000/img/yuangongDef.65d8327a.jpg"
          alt=""
        />

        <div>
          <div class="companyName">{{ item.cCusName }}</div>
          <div>
            客户经理:{{ item.AllocationName ? item.AllocationName : "无" }}
          </div>
        </div>
      </div>
      <div class="smallBox">
        <hr />
        <van-button size="small" type="default">报价</van-button>
        <van-button size="small" type="default">样品</van-button>
        <van-button size="small" type="default">返料</van-button>
      </div>
    </div>
    <!-- <Edit :parentObj="this" ref="edit" /> -->
  </div>
</template>

<script>
import { Card } from "vant";
import { Search, NavBar } from "vant";
// import Edit from "./Edit.vue";
export default {
  components: {
    "van-nav-bar": NavBar,
    "van-card": Card,
    "van-search": Search
    // Edit
  },
  data() {
    return {
      Keyword: "",
      data: [],
      queryParam: [{ condition: "cCusName" }]
    };
  },
  created() {
    this.getDataList();
  },
  methods: {
    clear() {
      this.queryParam = {};
      this.getDataList();
    },

    onClickLeft() {
      this.$router.go(-1);
    },
    onClickRight() {
      this.$refs.edit.openForm();
    },
    //弹出页面
    Edit(Id) {
      console.log("编辑", Id);
      // this.$refs.edit.openForm(Id);
    },
    //搜索
    search(value) {
      console.log(value);
      this.queryParam.Condition = "CustomerName";
      this.queryParam.Keyword = value;
      this.getDataList();
    },

    getDataList() {
      this.selectedRowKeys = [];

      this.loading = true;
      this.http
        .post(
          "/CustomerManagement/Customer/GetDataListByMySelfAndMoreCondition",
          {
            PageIndex: 1,
            PageRows: 99,
            SortField: "Id",
            SortType: "asc",
            Search: this.queryParam
          }
        )
        .then(resJson => {
          this.data = resJson.Data;
          // console.log(this.data);
        });
    }
  }
};
</script>

<style scoped>
.nav {
  position: fixed;
  width: 100%;
  /* top: 0; */
}
.companyName {
  margin-bottom: 5px;
  font-size: 18px;
}
.box {
  width: 80%;
  height: 150px;
  margin: 0 auto;
  margin-bottom: 10px;
  /* background-color: #7bbfea; */
  border-radius: 10px 10px 0 0;
  border-bottom: 1px solid #7bbfea;
  border-right: 1px solid #7bbfea;
}

.but {
  width: 20%;
  border-right: 1px solid #000;
}
img {
  width: 100px;
  height: 100px;
}
.Father {
  display: flex;
}
.smallBox {
  background-color: #fff;
}
</style>
